﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Jumpton.SFA.Server.BusinessRule.System;
using Jumpton.SFA.Server.Entity;
using Jumpton.SFA.Server.BusinessRule;
using BusinessRule.System;
public partial class UserDeviceInfo_List : PageBase
{
    private OrgainzationManager orgManager = new OrgainzationManager();
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {

            BindDeviceList();
        }
    }

    private void BindDeviceList()
    {
        //查询条件拼接
        string condition = "";
        if (this.txtLoginName.Text.Trim() != "")
        {
            condition += string.Format(" and  (u.CODE like '%{0}%' or p.NAME like '%{0}%' )", this.txtLoginName.Text.Trim());
        }

        switch (this.ddlDeviceStatus.SelectedValue)
        {
            case "1":
                //未绑定账户的设备
                condition += " and ud.ACTIVE is null ";
                break;
            case "2":
                //失效的设备
                condition += " and m.ACTIVE=0";
                break;
            case "3":
                //失效的设备
                condition += " and ud.ACTIVE=0";
                break;
            default:
                break;
        }
        GridPager1.DataSource = new MobileDeviceInfoManager().GetDeviceAndUserInfoByWhere(MyStateManager.DomainID, txtKeyWord.Text, condition);
        GridPager1.GridView = GridView1;
        GridPager1.BindData();
        GridPager1.Visible = GridView1.Rows.Count > 0;
    }

    public void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //if (e.Row.RowType == DataControlRowType.DataRow)
        //{
        //    Grid_RowDataBound(sender, e);
        //    LinkButton btnReset = (LinkButton)e.Row.Cells[4].FindControl("btnReset");
        //    btnReset.Attributes.Add("onClick", "return window.confirm('你确定要重置密码吗？');");
        //}
        //this.Grid_RowDataBound(sender, e);
    }

   

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BindDeviceList();
    }

    protected void btnQuery_Click(object sender, EventArgs e)
    {
        BindDeviceList();
    }
}

